<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>手写bind</title>
</head>
<body>
    <script>
        function test(){
            console.log(this,'this==========')
        }
        test()
        Function.prototype.mybind = function(){
            let self = this
            
            console.log(arguments,'arguments')
            // let a = Array.prototype.slice.call(arguments)
            let [a,...b] = arguments
            console.log(a)
            console.log(b)
            return function (){
                console.log(self)
                console.log(this)
                return self.apply(a,b)
            }
        }
        // test.bind({name:'Mfisher'})()
        // console.log(test.mybind({name : 'mfisher'},1,2,3,4,5))
        test.mybind({name : 'mfisher'},1,2,3,4,5)()
    </script>
</body>
</html>